import api from "@/api/api";
import {
  CUSTOMER_INFO,
  MERCHANT_INFO,
  USER_SPECICAL_INFO,
  USER_INFO,
} from "@/utils/constant";
import tip from "@/utils/tip";
import commonFunction from "@/utils/commonFunction.js";

export const checkFavStatus = async (outerItemId,type) => {
  let result;
  try {
    const customerInfo = uni.getStorageSync(CUSTOMER_INFO);
    const merchantInfo = uni.getStorageSync(MERCHANT_INFO)
    const res = await api.checkFavStatus({
      method: "POST",
      header: {
        jwt: customerInfo.jwt,
      },
      query: {
        referenceId: outerItemId,
        storeId: merchantInfo.cloudMerchantStoreId,
        type: type,
      },
    });
    if (res.code === 1000) {
      if (!!res.data.isFavorite) {
        result = true
      } else {
        result = false
      }
    }
  } catch (error) {
    // console.error("updatePolicyStatus error:", error);
  }
  return result
};
